import request from '@/utils/request';

export async function getProductDrawingInfoByPage(params: any) {
  return request('/api/design/getProductDrawingInfoByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addProductDrawingInfo(params: any) {
  return request('/api/design/addProductDrawingInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateProductDrawingInfo(params: any) {
  return request('/api/design/updateProductDrawingInfo', {
    method: 'POST',
    data: params,
  });
}

export async function delProductDrawingInfo(params: any) {
  return request('/api/design/delProductDrawingInfo', {
    method: 'POST',
    data: params,
  });
}

export async function exportProductDrawingInfo(params: any) {
  return request('/api/design/exportProductDrawingInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 上传图纸
export async function uploadDrawing(para: any) {
  return request('/api/design/uploadDrawing', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    params: {
      category: para.category,
      drawingSpec: para.drawingSpec,
      productCode: para.productCode,
    },
  });
}

// 图纸下载
export async function downloadProductDrawingInfo(para: any) {
  return request('/api/design/downloadProductDrawingInfo', {
    method: 'GET',
    responseType: 'blob',
    params: {
      id: para.id,
    },
  });
}

// 图纸启用禁用
export async function onIsActive(para: any) {
  return request('/api/design/onIsActive', {
    method: 'POST',
    params: {
      category: para.category,
      id: para.id,
      productCode: para.productCode,
    },
  });
}
export async function stopIsActive(para: any) {
  return request('/api/design/stopIsActive', {
    method: 'POST',
    params: {
      id: para.id,
    },
  });
}

// 获取图纸类型
export async function getDrawingTypeList(params: any) {
  return request('/api/design/getDrawingTypeList', {
    method: 'POST',
  });
}

// 变更图纸
export async function changeDrawing(para: any) {
  return request('/api/design/changeDrawing', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    params: {
      category: para.category,
      drawingSpec: para.drawingSpec,
      productCode: para.productCode,
    },
  });
}
// 变更图纸
export async function addMutiDrawingReview(para: any) {
  return request('/api/design/addMutiDrawingReview', {
    method: 'POST',
    data: para,
  });
}
export async function confirmDesignReview(para: any) {
  console.log(para.id);
  return request('/api/design/confirmDesignReview', {
    method: 'POST',
    data: para,
    params: {
      batchProductId: para.id,
      reviewState: para.changeStatus,
    },
  });
}

export default {
  getProductDrawingInfoByPage,
  addProductDrawingInfo,
  updateProductDrawingInfo,
  delProductDrawingInfo,
  exportProductDrawingInfo,
  addMutiDrawingReview,
  confirmDesignReview,
};
